<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML" 4.01"//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Created: August 15, 2001-->
<!--
$Id: SurveyResRec.php,v 1.8 2001/11/02 19:11:53 eugenem Exp $
$Header: /export/home/eugenem/public_html/ComplianceReports/RCS/SurveyResRec.php,v 1.8 2001/11/02 19:11:53 eugenem Exp $
$Log: SurveyResRec.php,v $
Revision 1.8  2001/11/02 19:11:53  eugenem
*** empty log message ***

Revision 1.7  2001/11/02 19:11:14  eugenem
Moved HTTP_*_VARS processing to dbc.inc

Revision 1.6  2001/11/02 15:00:50  eugenem
Moved database connect statements to a separate file.

Revision 1.5  2001/10/23 20:31:44  eugenem
Enabled script to handle HTTP_GET_VARS.
Display timestamps for recommendation added and resolved.

Revision 1.4  2001/09/05 19:55:51  eugenem
Add machine description to headers

Revision 1.3  2001/09/04 22:08:52  eugenem
Changed Recommendations table structure.

Revision 1.2  2001/08/16 17:54:51  eugenem
Don't print checkboxes when recommendation has been resolved.
If the Recommendation field is empty, don't print anything.

Revision 1.1  2001/08/16 14:48:45  eugenem
Initial revision

SurveyResRec.php
Resolve survey recommendations

First entry to the form presents the user with a drop down box containing a list
of survey IDs that have unresolved recommendations. Selecting a survey ID and
submitting the form sends the data back to this script to retrieve and display
the list of recommendations for the survey.

Unresolved recommendations are listed in bold font with a checkbox and additional
form elements to indicate the recommendation resolution date, Biomed work order
number, who the item was resolved and an optional service report upload. Submitting
the form sends the data to SurveyResolve.php
-->

<html>
<head>
<title>Radiological Equipment Database</title>
<meta name="author" content="Eugene Mah" />
<link rev="made" href="mailto:eugenem@ix.netcom.com" />
<link rev="home" href="http://blog.imabug.net/" />
<meta name="description" content="" />
<meta name="Keywords" content="" />
<meta name="Reply-to" content="eugenem@ix.netcom.com" />
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~0001))' />
<?PHP
require('functions.inc');
require('dbc.inc');

?>
<!--
This form provides a list of survey IDs to select from.  When a $SurveyID is selected, the DB is queried to retrieve
all the recommendations for $SurveyID.  Unresolved recommendations are displayed in bold with a checkbox.
Resolved recommendations are displayed normally with no checkbox.  The $SurveyID and $Resolved[] array containing
the RecIDs of the checked recommendations are passed to SurveyResolve.php.
-->
</head>

<body>
<h1>Radiological Equipment Database</h1>
<?PHP
if (isset($SurveyID)) {
  /*
    We have entered this form by submitting SurveyResRec.php.
    Go ahead and process the data submitted.
  */

  // Get the machine description for this surveyID
  $query = "select Description from Machines,TestDates where SurveyID=$SurveyID and Machines.MachineID=TestDates.MachineID AND Machines.Status=\"Active\"";
  $result = mysql_query($query);
  $row = mysql_fetch_row($result);
  $desc = $row[0];
  mysql_free_result($result);

  // Get the recommendations for the selected survey
  $query = "SELECT RecID,Recommendation,Resolved,RecAddTS,RecResolveTS,RecResolveDate,ResolvedBy,WONum,ServiceReportPath
            FROM Recommendations
            LEFT JOIN Survey2Machine USING (SurveyID)
            LEFT JOIN Machines USING (MachineID)
            WHERE Recommendations.SurveyID=$SurveyID AND Machines.Status=\"Active\"";
  $result = mysql_query($query)
    or die ("<p>Unable to execute query: $query</p>\n");
?>

<!-- Output the results into a form -->
<h2>Resolve Recommendations for <?PHP echo $desc; ?></h2>
<p>Unresolved recommendations are in bold with the checkbox in front</p>
<form action="SurveyResolve.php" method="POST" enctype="multipart/form-data">
<input type="HIDDEN" name="SurveyID" value="<?PHP echo $SurveyID; ?>">
<input type="HIDDEN" name="Description" value="<?PHP echo $desc; ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="8000000" />
<table>
  <tr>
    <th>Resolved</th><th>Recommendation</th><th>Date Added</th><th>Date Resolved</th><th>Work Order</th>
  </tr>
<?PHP
  while ($row = mysql_fetch_array($result)) {
    echo "<tr>\n";
    if ($row['Resolved']) {
      // Recommendation is already resolved.  Print the recommendaiton
      // but skip the checkbox
      echo "<td>&nbsp;</td>\n";
      echo "<td>" . $row['Recommendation'] . "</td>\n";
    }
    else {
      // Recommendation is not resolved yet.  Need a checkbox.
      // $Resolved[i] is passed to the next form only if checked
      echo "<td><input type=\"CHECKBOX\" name=\"Resolved[]\" value=" . $row['RecID'] . "></td>\n";
      echo "<td><b>" . $row['Recommendation'] . "</b></td>\n";
    }
    echo "<td>" . $row['RecAddTS'] . "</td>\n";
    echo "<td>";
    if (isset($row['RecResolveDate'])) echo $row['RecResolveDate'];
    else echo "NA";
    echo "</td>\n";
    if ($row['WONum'] <> "") {
      // If there is a workorder number, check if there is a service report (ServiceReportPath is not null)
      if (isset($row['ServiceReportPath'])) {
        // Link to the service report if there is one
        echo "<td><a href=\"" . $row['ServiceReportPath'] . "\">" . $row['WONum'] . "</a></td>\n";
      }
      else {
        // No service report. Just show the work order number
        echo "<td>" . $row['WONum'] . "</td>\n";
      }
    }
    else {
      echo "<td>&nbsp;</td>\n";
    }
    echo "</tr>\n";
  }
?>

</table>
<p>
Biomed Work Order Number: <input name="WONum" type="text" size="20" maxlength="20" /><br />
Resolution date: <input name="RecResolveDate" type="text" size="20" maxlength="20" /><br />
Upload service report: <input type="file" name="ServiceReport" /><br />
Resolved by: <input name="ResolvedBy" type="text" size="20" maxlength="20" />
</p>
<p><input type="SUBMIT" value="Resolve"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
<?PHP
}
?>

<h2>Resolve Recommendations</h2>
<form action="SurveyResRec.php" method="POST">
<p>Select a survey:

<?PHP
$survID = mysql_query("SELECT DISTINCT Recommendations.SurveyID
                       FROM Recommendations
                       LEFT JOIN Survey2Machine USING (SurveyID)
                       LEFT JOIN Machines USING (MachineID)
                       WHERE Resolved = 0 AND Machines.Status=\"Active\" ORDER BY Recommendations.SurveyID");
echo listbox_one_field($survID,"SurveyID","");
?>

</p>
<p><input type="SUBMIT" value="Get Recommendations"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
</body>
</html>
